package com.synjones.hymodule;



public class HYModuleControl {
	static
	{
		System.loadLibrary("finger");
		System.loadLibrary("hyzw");
	}

	public void powerOn(){
	}
	public void powerOff(){
	}

	public int openDev(){
		return openDevice("/dev/ttyMT1");
	}

	public int scanFinger(int timeout){
		long current=System.currentTimeMillis();
		int ret=scan(timeout);
		if(ret==0) return 0;
		timeout+=500;
		//等待模块内部执行完毕
		while(System.currentTimeMillis()-current<timeout){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {}
		}
		return ret;
	}

	public native int openDevice(String path);
	public native int closeDevice();
	public native int deviceCheck();
	public native int templateStart();
	public native int scan(int timeout);
	//public native int getImage(byte img[]);
	public native int getSensorType();
	public native int getImageFastFromSensor(int sensorType,byte img[]);
	/*
	public native int getBinImage(byte img[]);
	public native int getImageFast(byte img[]);
	public native int get360x256ImageFast(byte img[]);*/
	public native int genarateTemplateFromFile(String file1, String file2,String file3, int count, int needSameFinger,  byte Template[]);
	public native int fpMatch(byte Template[], byte Feature[], int sThreshold, int needUpdate[], byte updateTemplate[]);
	// uint8 GABTemplate[512]：512 字节公安部特征模板数据
	// uint8 sThreshold：比对相似度门限，默认值 40
	//
	// 返回 0 - 指令执行错误，1 - 比对通过，2 - 比对不通过，3 - 比对失败，数据有问题
	//
	public native int fpGABMatch(byte Template[],int sThreshold);
	public native int getFpFeature(byte feature[]);
	public native ImageQualityResult getImageQuality();

}
